﻿<?php


	 session_start();

          $_filename = (basename($_SERVER['SCRIPT_NAME'],'.php'));


              //判断是否勾选自动登录
             if(empty($_GET['out']) && empty($_SESSION['admin']) && !empty($_COOKIE['auto_login1']) && !empty($_COOKIE['name']) && !empty($_COOKIE['password'])){
             	$_SESSION['admin']['name'] = $_COOKIE['name'];

             	//判断是否是登录页面，是就强制到后台首页 否就正常显示要访问的页面
             	if($_filename=='login1'){
             		header('location:index.php');
             	}else{
             		header('location:'.$_filename.'.php');
             	}
             }


				 //判断session不为空且登录的是登录页面也强制跳到后台首页

			 if(empty($_SESSION['admin']) && $_filename=='login1'){

			 	    header('location:index.php');
			 }


			 //判断用户是否登录

            $allow=array(' ','home');





			if(empty($_SESSION['admin']) && $a!='login1' && $a!='code'&& $a!='logout'&!in_array($admin,$allow)){







				echo '<script>alert("请先登录");location.href="index.php?c=admin&a=login1&admin=1";</script>';

			}
		// if(empty($_SESSION['admin'])){

		// 	echo '<script>alert("请先登录"); </script>';
	 // }



							 //链接数据库
	 $link = mysqli_connect('127.0.0.1', 'root', 'root', 'p301');


										//中文编码
						 mysqli_query($link,'set names utf8');


                        $_filename='protected/View/admin/'.$c.'/'.$a.'.html';

						 // $tame=basename($_SERVER['PHP_SELF'],'.php');

       include_once (LIB_PATH.'thumb.php');

       include_once (LIB_PATH.'potting.php');

       include_once (LIB_PATH.'thumb.php');





